package com.volcreate.inn.utils;

import java.util.ArrayList;
import java.util.List;

/**
 * @author zxc
 * @version 0.0.2
 * @date 2020/8/25
 */
public class MyListAndStringUtils {

    /**
     * list [1,2,3] to "1,2,3"
     *
     * @param list
     * @return
     */
    public static String ListToSqlString(List list) {
        String s = list.toString();
        return s.substring(1, s.length() - 1);
    }

    /**
     * "1,2,3" to list [1,2,3]
     *
     * @param ids
     * @return
     */
    public static List<Long> stringToList(String ids) {
        List<Long> list = new ArrayList<>();
        if (!"".equals(ids) && ids != null) {
            String[] idarray = ids.split(",");
            for (int i = 0; i < idarray.length; i++) {
                list.add(new Long(idarray[i]));
            }
        }
        return list;
    }

}
